import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/home/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
      meta: {
        title: '主页',
      },
    },
    {
      path: '/sample-chat',
      name: 'SampleChat',
      component: () => import('@/views/sample-chat/index.vue'),
      meta: {
        title: '聊一聊',
      },
    },
  ],
})

router.afterEach((to, from) => {
  setTimeout(() => {
    window.document.title = to.meta.title ? to.meta.title as string : '页面仔';
  }, 0);
})

export default router
